package com.dbiservices.dbiworker.configuration;

import java.util.Map.Entry;
import java.util.Properties;

import org.apache.log4j.Logger;

import com.dbiservices.dbiworker.utils.Map;


public class Context {
	
	public static final String iE_PLUGIN_HANDLER						= "plugin.handler";
	public static final String iE_MAIN_WINDOW							= "main.window";
	public static final String iE_MAIN_MODEL							= "main.model";
	
	public static final String iP_PLUGIN_FOLDER							= "main.plugin.folder";
	
	private static Map<String,Object> parameters = new Map<String,Object>();
	private static Logger log = Logger.getLogger(Context.class);
	
	public static void feed(Properties properties){
		for(Entry<Object,Object> entry : properties.entrySet()){
			add((String)entry.getKey(), entry.getValue());
		}
	}
	
	public static int size(){
		return parameters.size();
	}
	
	public static void add(String key, Object value){
		parameters.put(key, value);
		log.debug("Added parameter "+key+" to Context");
	}
	
	public static Object get(String key){
		return parameters.get(key);
	}
	
	public static Integer getInteger(String key){
		return Integer.parseInt((String)parameters.get(key));
	}
	
	public static String getString(String key){
		return (String)parameters.get(key);
	}
	
	public static boolean getBoolean(String key){
		return Boolean.getBoolean((String)parameters.get(key));
	}
}
